//package declaration
package pxgrid_entities;

//imports
import java.util.ArrayList;

/**
 * PXJob
 * A entity class to store attributes about a submission.
 * 
 * @author Mark Bate
 */
public class PXSubmission {

    //variables
    private String submission_id;
    private String directory_path;
    private String email_address;
    private ArrayList<PXJob> jobs;
    
    /**
     * constructor
     */
    public PXSubmission() {
        this.jobs = new ArrayList();
    }
    
    //set methods
    
    /**
     * sets the submission ID of this submission
     * @param submission_id String the ID to use to refer to this submission
     */
    public void setSubmissionID(String submission_id) {
        this.submission_id = submission_id;
    }
    
    /**
     * sets the Directory Path () of this submission
     * @param directory_path String the Directory Path () of this submission
     */
    public void setDirectoryPath(String directory_path) {
        this.directory_path = directory_path;
    }
    
    //METHOD NOT YET USED
    
    /**
     * sets the Email Address to associate with this submission
     * @param email_address String the email address
     * @throws java.lang.Exception thrown if the email doesn't look valid
     */
    public void setEmailAddress(String email_address) throws Exception {
        if(email_address.contains("@") && email_address.contains("."))
            this.email_address = email_address;
        else
            throw new Exception("email address does not appear to be valid");
    }
    
    //job manipulation methods
    
    /**
     * Adds a new PXJob to the jobs ArrayList
     * @param job PXJob the job to add
     */
    public void addJob(PXJob job) {
        this.jobs.add(job);
    }
    
    /**
     * Remove the PXJob at position "index" from the jobs ArrayList 
     * @param index int the position of the PXJob to remove from the jobs ArrayList
     */
    public void removeJobAtIndex(int index) {
        this.jobs.remove(index);
    }
    
    /**
     * completely wipes clean the jobs ArrayList
     */
    public void removeAllJobs() {
        this.jobs.clear();
    }
    
    
    // get methods
    
    /**
     * gets the submission ID of the submission
     * @return String the submission ID
     */
    public String getSubmissionID() {
        return this.submission_id;
    }
    
    /**
     * gets the directory path of the submission
     * @return String the directory path of the submission
     */
    public String getDirectoryPath() {
        return this.directory_path;
    }
    
    //METHOD NOT USED
    
    /**
     * gets the email address for the submission
     * @return String the email address for the submission
     */
    public String getEmailAddress() {
        return this.email_address;
    }

    /**
     * gets the ArrayList of jobs associated with this submission
     * @return ArrayList the jobs associated with this submission
     */
    public ArrayList<PXJob> getJobs() {
        return this.jobs;
    }
}
